/** 
* Copyright (C) 2012-2017 ZEEI Inc.All Rights Reserved.
* 项目名称：pls
* 文件名称：GasPointServiceImpl.java
* 包  名  称：com.zeei.app.service.impl
* 文件描述：TODO 请修改文件描述
* 创建日期：2017年12月19日上午11:05:03
* 
* 修改历史
* 1.0 chenhuiqiong 2017年12月19日上午11:05:03 创建文件
*
*/


package com.zeei.app.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zeei.app.constant.PointConstant;
import com.zeei.app.dao.GasPointDao;
import com.zeei.app.service.GasPointService;
import com.zeei.app.vo.GasPointListVO;
import com.zeei.app.vo.GasPointPolluteLimit;
import com.zeei.app.vo.GasPointPolluteLimitInorg;
import com.zeei.app.vo.GasPointPolluteLimitSpecial;
import com.zeei.app.vo.GasPolluteCountVO;
import com.zeei.common.utils.StringUtil;

/** 
* 类型名称：GasPointServiceImpl
* 类型描述：废气排口管理
* 功能描述：废气排口管理
* 创建作者：chenhuiqiong
*
*/
@Service("gasPointService")
public class GasPointServiceImpl implements GasPointService{

	@Autowired
	private GasPointDao gasPointDao;
	
	
	/* (non-Javadoc)
	 * @see com.zeei.app.service.GasPointService#queryPointInfo(com.zeei.app.vo.GasPointListVO)
	 */
	@Override
	public List<GasPointListVO> queryPointInfo(GasPointListVO gasPointListVO) {
		List<GasPointListVO> pointList = gasPointDao.queryPointInfo(gasPointListVO);
		List<GasPointPolluteLimit> polluteLimitList = gasPointDao.queryGasPointPolluteLimit(gasPointListVO);
		for(GasPointListVO gasPoint : pointList){
			polluteLimitList.stream().filter(s -> gasPoint.getPsCode().equals(s.getPsCode()) && gasPoint.getPointCode().equals(s.getPointCode())).forEach(s -> setParamData(gasPoint,s));  
		}
		return pointList;
	}

	/**
	 * 
	 * setParamData:设置排口有组织限值,同时设置排口类型(有组织[0])
	 * 
	 * @param gasPoint
	 * @param gasPointPolluteLimit
	 * @param gasPointPolluteLimitInorg void
	 */
	private void setParamData(GasPointListVO gasPoint,GasPointPolluteLimit gasPointPolluteLimit){
	    	gasPoint.setGasPointPolluteLimits(gasPointPolluteLimit);
		gasPoint.setInorg(PointConstant.YES_NORG_POINT);

	}

	/* (non-Javadoc)
	 * @see com.zeei.app.service.GasPointService#queryGasPolluteCount(com.zeei.app.vo.GasPolluteCountVO)
	 */
	@Override
	public List<GasPolluteCountVO> queryGasPolluteCount(GasPolluteCountVO gasPolluteCount) {
	    
	    return gasPointDao.queryGasPolluteCount(gasPolluteCount);
	    
	}

	/* (non-Javadoc)
	 * @see com.zeei.app.service.GasPointService#queryGasPointPolluteLimitSpecial(com.zeei.app.vo.GasPointPolluteLimitSpecial)
	 */
	@Override
	public List<GasPointPolluteLimitSpecial> queryGasPointPolluteLimitSpecial(GasPointPolluteLimitSpecial gasPointPolluteLimitSpecial) {
	    List<GasPointPolluteLimitSpecial> polluteLimitSpecialList = new ArrayList<GasPointPolluteLimitSpecial>();
	    
	    if(StringUtil.isNotEmpty(gasPointPolluteLimitSpecial.getPointType())){
		
		List<GasPointPolluteLimitSpecial> temp = gasPointDao.queryGasPointPolluteLimitSpecial(gasPointPolluteLimitSpecial);
		polluteLimitSpecialList.addAll(temp);
		
	    }else if(StringUtil.isNotEmpty(gasPointPolluteLimitSpecial.getType())){
		
		List<GasPointPolluteLimitSpecial> temp = gasPointDao.queryGasPointPolluteLimitSpecialCount(gasPointPolluteLimitSpecial);
		polluteLimitSpecialList.addAll(temp);
		
	    }else if(StringUtil.isEmpty(gasPointPolluteLimitSpecial.getPointType()) && StringUtil.isEmpty(gasPointPolluteLimitSpecial.getType())){
		
		List<GasPointPolluteLimitSpecial> temp = gasPointDao.queryGasPointPolluteLimitSpecial(gasPointPolluteLimitSpecial);
		List<GasPointPolluteLimitSpecial> tempCount = gasPointDao.queryGasPointPolluteLimitSpecialCount(gasPointPolluteLimitSpecial);
		polluteLimitSpecialList.addAll(temp);
		polluteLimitSpecialList.addAll(tempCount);
		
	    }
	    return polluteLimitSpecialList;
	    
	}

	/* (non-Javadoc)
	 * @see com.zeei.app.service.GasPointService#queryGasPointPolluteLimitInorg(com.zeei.app.vo.GasPointPolluteLimitInorg)
	 */
	@Override
	public List<GasPointPolluteLimitInorg> queryGasPointPolluteLimitInorg(GasPointPolluteLimitInorg gasPointPolluteLimitInorg) {
	    List<GasPointPolluteLimitInorg> polluteLimitInorgList = gasPointDao.queryGasPointPolluteLimitInorg(gasPointPolluteLimitInorg);
	    return polluteLimitInorgList;
	}

	/* (non-Javadoc)
	 * @see com.zeei.app.service.GasPointService#queryGasPolluteTotalLimit(com.zeei.app.vo.GasPointPolluteLimitInorg)
	 */
	@Override
	public List<GasPointPolluteLimitInorg> queryGasPolluteTotalLimit(
		GasPointPolluteLimitInorg gasPointPolluteLimitInorg) {
	    
	    return gasPointDao.queryGasPolluteTotalLimit(gasPointPolluteLimitInorg);
	    
	}
	
	
}

